new Vue({
  el: "#app",
  data() {
    return {
      ye: 1,
      BASE_IMG: "https://www.kdddy.cn/Image/",
      form: {
        SQLSerialNumber: "select_base_EdibleMushroomVariety",
        PaginationNumber: 1, //页数
        RowAmount: 15, //每页数据条数
        // Category_Name: "",
        Condition: "",
        ExtensionCondition: "",
      },
      total: 0,
      Total: 0,
      tableData: [], //表格数据
      Acquisition: [],
    };
  },
  mounted() {
    // this.getList(this.form);
    this.xianshi(this.ye);
  },
  methods: {
    handleCurrentChange(arg) {
      this.xianshi(arg);
    },
    onSerach() {
      console.log(this.form.VarietyName);
      this.xianshi(this.ye, this.form.VarietyName);
      //查询方法
      // this.form.PaginationNumber = 1;
      // this.getList(this.form);
    },
    Add() {
      window.location.href = "./add.html";
    },
    handleSizeChange(val) {
      this.form.PaginationNumber = 1;
      this.form.RowAmount = val;
      this.getList(this.form);
    },
    // handleCurrentChange(val) {
    //   this.form.PaginationNumber = val;
    //   this.getList(this.form);
    // },
    xianshi(arg, VarietyName) {
      if (VarietyName == undefined) {
        VarietyName = "";
      }
      console.log(arg, VarietyName);
      //换页方法
      const _this = this;
      // return
      $.ajax({
        // headers: requestHeaders(),
        // url: `${BASE_URL2}/generalBusiness/generalPaginationQueryBySQLSerialNumber`,
        url: "https://service.kdddy.cn/donghui/login/generalQueryByTableNameAndPaginationForClient",
        type: "post",
        data: {
          Data: "base_EdibleMushroomVariety", //表名
          Condition:
            "Row_Status='0' and VarietyName LIKE '%" + VarietyName + "%'",
          PageNubmer: arg,
          RowAmount: 15,
        },
        success: function (Result) {
          console.log(Result);
          _this.tableData = Result[0].Rows;
          _this.Total = Result[0].Total;
        },
        // complete: function (XMLHttpRequest) {
        //   requestPretreatment(XMLHttpRequest); //config/config.js 响应预检
        // },
        dataType: "json",
      });
    },
    Edit(index, row) {
      row.VarietyID;
      console.log(row);
      console.log(index);

      sessionStorage.setItem("VarietylD", row.VarietyID);
      window.location.href =
        "./edit.html?Category_SerialNumber=" + row.VarietyID;
    },
    Remove(index, row) {
      console.log(row);
      row.Row_Status = 1;
      let lArray = new Array();
      lArray.push(row);
      let lJSONObject_base_EdibleMushroomVariety = new Object();
      lJSONObject_base_EdibleMushroomVariety.base_EdibleMushroomVariety =
        lArray; //换表
      let lJSONObject_DataSet = new Object(); //Modify
      lJSONObject_DataSet.Modify = lJSONObject_base_EdibleMushroomVariety; //换表
      const _this = this;
      $.ajax({
        // headers: requestHeaders(),
        // url: `${BASE_URL2}/generalBusiness/generalPaginationQueryBySQLSerialNumber`,
        url: "https://service.kdddy.cn/donghui/clientOperation/generalSaveForClient",
        type: "POST",
        data: {
          Data: JSON.stringify(lJSONObject_DataSet),
        },
        success: function (Result) {
          console.log(Result);
          if (Result.Status == "success") {
            _this.tableData.splice(index, 1);
          }
          // if (Result.Status === "success") {
          //   _this.$message.success("提交成功");

          // } else {
          //   _this.$message.error("提交失败，请稍后再试");
          // }
        },
        complete: function (XMLHttpRequest) {
          requestPretreatment(XMLHttpRequest); //config/config.js 响应预检
        },
        dataType: "json",
      });
      // this.$confirm("警告！此操作将删除该类别, 是否继续?", "提示", {
      //   confirmButtonText: "确定",
      //   cancelButtonText: "取消",
      //   type: "warning",
      // })
      // .then(() => {
      //   row.Row_Status = "1";
      //   $.ajax({
      //     headers: requestHeaders(),
      //     url: "https://service.kdddy.cn/donghui/clientOperation/generalSaveForClient",
      //     type: "POST",
      //     data: {
      //       Data: JSON.stringify({ Modify: { business_category: [row] } }),
      //     },
      //     success: function (res) {
      //       if (res.Status === "success") {
      //         that.$message({
      //           type: "success",
      //           message: "删除成功!",
      //         });
      //         that.xianshi(that.form);
      //       } else {
      //         that.$message.error("删除失败，请稍后再试");
      //       }
      //     },
      //     complete: function (XMLHttpRequest) {
      //       that.loading = false;
      //       requestPretreatment(XMLHttpRequest); //config/config.js 响应预检
      //     },
      //     dataType: "json",
      //   });
      // })
      // .catch(() => {});
    },
  },
});
